home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / wgdb-42.lha / wgdb-4.2 / gdb / tm-29k.h < prev    next >
Text File  |  1992-09-11  |  27KB  |  673 lines

  1. /* Parameters for target machine of AMD 29000, for GDB, the GNU debugger.
  2.    Copyright 1990, 1991 Free Software Foundation, Inc.
  3.    Contributed by Cygnus Support.  Written by Jim Kingdon.
  4.  
  5. This file is part of GDB.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* Parameters for an EB29K (a board which plugs into a PC and is
  22.    accessed through EBMON software running on the PC, which we
  23.    use as we'd use a remote stub (see remote-eb.c).
  24.  
  25.    If gdb is ported to other 29k machines/systems, the
  26.    machine/system-specific parts should be removed from this file (a
  27.    la tm-68k.h).  */
  28.  
  29. /* Byte order is configurable, but this machine runs big-endian.  */
  30. #define TARGET_BYTE_ORDER BIG_ENDIAN
  31.  
  32. /* Floating point uses IEEE representations.  */
  33. #define IEEE_FLOAT
  34.  
  35. /* Recognize our magic number.  */
  36. #define BADMAG(x) ((x).f_magic != 0572)
  37.  
  38. /* Define this if the C compiler puts an underscore at the front
  39.    of external names before giving them to the linker.  */
  40.  
  41. #define NAMES_HAVE_UNDERSCORE
  42.  
  43. /* Offset from address of function to start of its code.
  44.    Zero on most machines.  */
  45.  
  46. #define FUNCTION_START_OFFSET 0
  47.  
  48. /* Advance PC across any function entry prologue instructions
  49.    to reach some "real" code.  */
  50.  
  51. #define SKIP_PROLOGUE(pc) \
  52.   { pc = skip_prologue (pc); }
  53. CORE_ADDR skip_prologue ();
  54.  
  55. /* Immediately after a function call, return the saved pc.
  56.    Can't go through the frames for this because on some machines
  57.    the new frame is not set up until the new function executes
  58.    some instructions.  */
  59.  
  60. #define SAVED_PC_AFTER_CALL(frame) (read_register (LR0_REGNUM))
  61.  
  62. /* I'm not sure about the exact value of this, but based on looking
  63.    at the stack pointer when we get to main this seems to be right.
  64.  
  65.    This is the register stack; We call it "CONTROL" in GDB for consistency
  66.    with Pyramid.  */
  67. #define CONTROL_END_ADDR 0x80200000
  68.  
  69. /* Memory stack.  This is for the default register stack size, which is
  70.    only 0x800 bytes.  Perhaps we should let the user specify stack sizes
  71.    (and tell EBMON with the "ZS" command).  */
  72. #define STACK_END_ADDR 0x801ff800
  73.  
  74. /* Stack grows downward.  */
  75.  
  76. #define INNER_THAN <
  77.  
  78. /* Stack must be aligned on 32-bit word boundaries.  */
  79. #define STACK_ALIGN(ADDR) (((ADDR) + 3) & ~3)
  80.  
  81. /* Sequence of bytes for breakpoint instruction.  */
  82. /* ASNEQ 0x50, gr1, gr1
  83.    The trap number 0x50 is chosen arbitrarily.  */
  84. #if TARGET_BYTE_ORDER == BIG_ENDIAN
  85. #define BREAKPOINT {0x72, 0x50, 0x01, 0x01}
  86. #else /* Target is little-endian.  */
  87. #define BREAKPOINT {0x01, 0x01, 0x50, 0x72}
  88. #endif /* Target is little-endian.  */
  89.  
  90. /* Amount PC must be decremented by after a breakpoint.
  91.    This is often the number of bytes in BREAKPOINT
  92.    but not always.  */
  93.  
  94. #define DECR_PC_AFTER_BREAK 4
  95.  
  96. /* Nonzero if instruction at PC is a return instruction.
  97.    On the 29k, this is a "jmpi l0" instruction.  */
  98.  
  99. #define ABOUT_TO_RETURN(pc) \
  100.   ((read_memory_integer (pc, 4) & 0xff0000ff) == 0xc0000080)
  101.  
  102. /* Return 1 if P points to an invalid floating point value.  */
  103.  
  104. #define INVALID_FLOAT(p, len) 0   /* Just a first guess; not checked */
  105.  
  106. /* Say how long (ordinary) registers are.  */
  107.  
  108. #define REGISTER_TYPE long
  109.  
  110. /* Allow the register declarations here to be overridden for remote
  111.    kernel debugging.  */
  112. #if !defined (REGISTER_NAMES)
  113.  
  114. /* Number of machine registers */
  115.  
  116. #define NUM_REGS 205
  117.  
  118. /* Initializer for an array of names of registers.
  119.    There should be NUM_REGS strings in this initializer.
  120.  
  121.    FIXME, add floating point registers and support here.
  122.  
  123.    Also note that this list does not attempt to deal with kernel
  124.    debugging (in which the first 32 registers are gr64-gr95).  */
  125.  
  126. #define REGISTER_NAMES \
  127. {"gr96", "gr97", "gr98", "gr99", "gr100", "gr101", "gr102", "gr103", "gr104", \
  128.  "gr105", "gr106", "gr107", "gr108", "gr109", "gr110", "gr111", "gr112", \
  129.  "gr113", "gr114", "gr115", "gr116", "gr117", "gr118", "gr119", "gr120", \
  130.  "gr121", "gr122", "gr123", "gr124", "gr125", "gr126", "gr127",         \
  131.  "lr0", "lr1", "lr2", "lr3", "lr4", "lr5", "lr6", "lr7", "lr8", "lr9",   \
  132.  "lr10", "lr11", "lr12", "lr13", "lr14", "lr15", "lr16", "lr17", "lr18", \
  133.  "lr19", "lr20", "lr21", "lr22", "lr23", "lr24", "lr25", "lr26", "lr27", \
  134.  "lr28", "lr29", "lr30", "lr31", "lr32", "lr33", "lr34", "lr35", "lr36", \
  135.  "lr37", "lr38", "lr39", "lr40", "lr41", "lr42", "lr43", "lr44", "lr45", \
  136.  "lr46", "lr47", "lr48", "lr49", "lr50", "lr51", "lr52", "lr53", "lr54", \
  137.  "lr55", "lr56", "lr57", "lr58", "lr59", "lr60", "lr61", "lr62", "lr63", \
  138.  "lr64", "lr65", "lr66", "lr67", "lr68", "lr69", "lr70", "lr71", "lr72", \
  139.  "lr73", "lr74", "lr75", "lr76", "lr77", "lr78", "lr79", "lr80", "lr81", \
  140.  "lr82", "lr83", "lr84", "lr85", "lr86", "lr87", "lr88", "lr89", "lr90", \
  141.  "lr91", "lr92", "lr93", "lr94", "lr95", "lr96", "lr97", "lr98", "lr99", \
  142.  "lr100", "lr101", "lr102", "lr103", "lr104", "lr105", "lr106", "lr107", \
  143.  "lr108", "lr109", "lr110", "lr111", "lr112", "lr113", "lr114", "lr115", \
  144.  "lr116", "lr117", "lr118", "lr119", "lr120", "lr121", "lr122", "lr123", \
  145.  "lr124", "lr125", "lr126", "lr127",                     \
  146.   "AI0", "AI1", "AI2", "AI3", "AI4", "AI5", "AI6", "AI7", "AI8", "AI9",  \
  147.   "AI10", "AI11", "AI12", "AI13", "AI14", "AI15", "FP",             \
  148.   "bp", "fc", "cr", "q",                         \
  149.   "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr",     \
  150.   "pc0", "pc1", "pc2", "mmu", "lru", "fpe", "int", "fps", "exo", "gr1",  \
  151.   "alu", "ipc", "ipa", "ipb" }
  152.  
  153. /* Convert Processor Special register #x to REGISTER_NAMES register # */
  154. #define SR_REGNUM(x) \
  155.   ((x) < 15  ? VAB_REGNUM + (x)                     \
  156.    : (x) >= 128 && (x) < 131 ? IPC_REGNUM + (x) - 128         \
  157.    : (x) == 131 ? Q_REGNUM                     \
  158.    : (x) == 132 ? ALU_REGNUM                     \
  159.    : (x) >= 133 && (x) < 136 ? BP_REGNUM + (x) - 133         \
  160.    : (x) >= 160 && (x) < 163 ? FPE_REGNUM + (x) - 160         \
  161.    : (x) == 164 ? EXO_REGNUM                                     \
  162.    : (error ("Internal error in SR_REGNUM"), 0))
  163. #define GR96_REGNUM 0
  164. /* Define the return register separately, so it can be overridden for
  165.    kernel procedure calling conventions. */
  166. #define    RETURN_REGNUM    GR96_REGNUM
  167. #define GR1_REGNUM 200
  168. /* This needs to be the memory stack pointer, not the register stack pointer,
  169.    to make call_function work right.  */
  170. #define SP_REGNUM MSP_REGNUM
  171. #define FP_REGNUM 33 /* lr1 */
  172. /* Large Return Pointer (gr123).  */
  173. #define LRP_REGNUM (123 - 96 + GR96_REGNUM)
  174. /* Static link pointer (gr124).  */
  175. #define SLP_REGNUM (124 - 96 + GR96_REGNUM)
  176. /* Memory Stack Pointer (gr125).  */
  177. #define MSP_REGNUM (125 - 96 + GR96_REGNUM)
  178. /* Register allocate bound (gr126).  */
  179. #define RAB_REGNUM (126 - 96 + GR96_REGNUM)
  180. /* Register Free Bound (gr127).  */
  181. #define RFB_REGNUM (127 - 96 + GR96_REGNUM)
  182. /* Register Stack Pointer.  */
  183. #define RSP_REGNUM GR1_REGNUM
  184. #define LR0_REGNUM 32
  185. #define BP_REGNUM 177
  186. #define FC_REGNUM 178
  187. #define CR_REGNUM 179
  188. #define Q_REGNUM 180
  189. #define VAB_REGNUM 181
  190. #define OPS_REGNUM (VAB_REGNUM + 1)
  191. #define CPS_REGNUM (VAB_REGNUM + 2)
  192. #define CFG_REGNUM (VAB_REGNUM + 3)
  193. #define CHA_REGNUM (VAB_REGNUM + 4)
  194. #define CHD_REGNUM (VAB_REGNUM + 5)
  195. #define CHC_REGNUM (VAB_REGNUM + 6)
  196. #define RBP_REGNUM (VAB_REGNUM + 7)
  197. #define TMC_REGNUM (VAB_REGNUM + 8)
  198. #define TMR_REGNUM (VAB_REGNUM + 9)
  199. #define NPC_REGNUM (VAB_REGNUM + 10)  /* pc0 */
  200. #define PC_REGNUM  (VAB_REGNUM + 11)  /* pc1 */
  201. #define PC2_REGNUM (VAB_REGNUM + 12)
  202. #define MMU_REGNUM (VAB_REGNUM + 13)
  203. #define LRU_REGNUM (VAB_REGNUM + 14)
  204. #define FPE_REGNUM (VAB_REGNUM + 15)
  205. #define INT_REGNUM (VAB_REGNUM + 16)
  206. #define FPS_REGNUM (VAB_REGNUM + 17)
  207. #define EXO_REGNUM (VAB_REGNUM + 18)
  208. /* gr1 is defined above as 200 = VAB_REGNUM + 19 */
  209. #define ALU_REGNUM (VAB_REGNUM + 20)
  210. #define PS_REGNUM  ALU_REGNUM
  211. #define IPC_REGNUM (VAB_REGNUM + 21)
  212. #define IPA_REGNUM (VAB_REGNUM + 22)
  213. #define IPB_REGNUM (VAB_REGNUM + 23)
  214.  
  215. #endif    /* !defined(REGISTER_NAMES) */
  216.  
  217. /* Total amount of space needed to store our copies of the machine's
  218.    register state, the array `registers'.  */
  219. #define REGISTER_BYTES (NUM_REGS * 4)
  220.  
  221. /* Index within `registers' of the first byte of the space for
  222.    register N.  */
  223. #define REGISTER_BYTE(N)  ((N)*4)
  224.  
  225. /* Number of bytes of storage in the actual machine representation
  226.    for register N.  */
  227.  
  228. /* All regs are 4 bytes.  */
  229.  
  230. #define REGISTER_RAW_SIZE(N) (4)
  231.  
  232. /* Number of bytes of storage in the program's representation
  233.    for register N.  */
  234.  
  235. /* All regs are 4 bytes.  */
  236.  
  237. #define REGISTER_VIRTUAL_SIZE(N) (4)
  238.  
  239. /* Largest value REGISTER_RAW_SIZE can have.  */
  240.  
  241. #define MAX_REGISTER_RAW_SIZE (4)
  242.  
  243. /* Largest value REGISTER_VIRTUAL_SIZE can have.  */
  244.  
  245. #define MAX_REGISTER_VIRTUAL_SIZE (4)
  246.  
  247. /* Nonzero if register N requires conversion
  248.    from raw format to virtual format.  */
  249.  
  250. #define REGISTER_CONVERTIBLE(N) (0)
  251.  
  252. /* Convert data from raw format for register REGNUM
  253.    to virtual format for register REGNUM.  */
  254.  
  255. #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
  256. { bcopy ((FROM), (TO), 4); }
  257.  
  258. /* Convert data from virtual format for register REGNUM
  259.    to raw format for register REGNUM.  */
  260.  
  261. #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO)    \
  262. { bcopy ((FROM), (TO), 4); }
  263.  
  264. /* Return the GDB type object for the "standard" data type
  265.    of data in register N.  */
  266.  
  267. #define REGISTER_VIRTUAL_TYPE(N) \
  268.   (((N) == PC_REGNUM || (N) == LRP_REGNUM || (N) == SLP_REGNUM         \
  269.     || (N) == MSP_REGNUM || (N) == RAB_REGNUM || (N) == RFB_REGNUM     \
  270.     || (N) == GR1_REGNUM || (N) == FP_REGNUM || (N) == LR0_REGNUM       \
  271.     || (N) == NPC_REGNUM || (N) == PC2_REGNUM)                           \
  272.    ? lookup_pointer_type (builtin_type_void) : builtin_type_int)
  273.  
  274. /* Store the address of the place in which to copy the structure the
  275.    subroutine will return.  This is called from call_function. */
  276. /* On the 29k the LRP points to the part of the structure beyond the first
  277.    16 words.  */
  278. #define STORE_STRUCT_RETURN(ADDR, SP) \
  279.   write_register (LRP_REGNUM, (ADDR) + 16 * 4);
  280.  
  281. /* Should call_function allocate stack space for a struct return?  */
  282. /* On the 29k objects over 16 words require the caller to allocate space.  */
  283. #define USE_STRUCT_CONVENTION(gcc_p, type) (TYPE_LENGTH (type) > 16 * 4)
  284.  
  285. /* Extract from an array REGBUF containing the (raw) register state
  286.    a function return value of type TYPE, and copy that, in virtual format,
  287.    into VALBUF.  */
  288.  
  289. #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF)          \
  290.   {                                                                                                   \
  291.     int reg_length = TYPE_LENGTH (TYPE);                   \
  292.     if (reg_length > 16 * 4)                           \
  293.       {                                       \
  294.     reg_length = 16 * 4;                           \
  295.     read_memory (*((int *)(REGBUF) + LRP_REGNUM), (VALBUF) + 16 * 4,   \
  296.              TYPE_LENGTH (TYPE) - 16 * 4);               \
  297.       }                                       \
  298.     bcopy (((int *)(REGBUF))+RETURN_REGNUM, (VALBUF), reg_length);       \
  299.   }
  300.  
  301. /* Write into appropriate registers a function return value
  302.    of type TYPE, given in virtual format.  */
  303.  
  304. #define STORE_RETURN_VALUE(TYPE,VALBUF) \
  305.   {                                      \
  306.     int reg_length = TYPE_LENGTH (TYPE);                  \
  307.     if (reg_length > 16 * 4)                          \
  308.       {                                      \
  309.         reg_length = 16 * 4;                          \
  310.         write_memory (read_register (LRP_REGNUM),              \
  311.               (char *)(VALBUF) + 16 * 4,              \
  312.               TYPE_LENGTH (TYPE) - 16 * 4);              \
  313.       }                                      \
  314.     write_register_bytes (REGISTER_BYTE (RETURN_REGNUM), (char *)(VALBUF),  \
  315.               TYPE_LENGTH (TYPE));                  \
  316.   }
  317.  
  318. /* The am29k user's guide documents well what the stacks look like.
  319.    But what isn't so clear there is how this interracts with the
  320.    symbols, or with GDB.
  321.    In the following saved_msp, saved memory stack pointer (which functions
  322.    as a memory frame pointer), means either
  323.    a register containing the memory frame pointer or, in the case of
  324.    functions with fixed size memory frames (i.e. those who don't use
  325.    alloca()), the result of the calculation msp + msize.
  326.  
  327.    LOC_ARG, LOC_LOCAL - For GCC, these are relative to saved_msp.
  328.      For high C, these are relative to msp (making alloca impossible).
  329.    LOC_REGISTER, LOC_REGPARM - The register number is the number at the
  330.      time the function is running (after the prologue), or in the case
  331.      of LOC_REGPARM, may be a register number in the range 160-175.
  332.  
  333.    The compilers do things like store an argument into memory, and then put out
  334.    a LOC_ARG for it, or put it into global registers and put out a
  335.    LOC_REGPARM.  Thus is it important to execute the first line of
  336.    code (i.e. the line of the open brace, i.e. the prologue) of a function
  337.    before trying to print arguments or anything.
  338.  
  339.    The following diagram attempts to depict what is going on in memory
  340.    (see also the _am29k user's guide_) and also how that interacts with
  341.    GDB frames.  We arbitrarily pick fci->frame to point the same place
  342.    as the register stack pointer; since we set it ourself in
  343.    INIT_EXTRA_FRAME_INFO, and access it only through the FRAME_*
  344.    macros, it doesn't really matter exactly how we
  345.    do it.  However, note that FRAME_FP is used in two ways in GDB:
  346.    (1) as a "magic cookie" which uniquely identifies frames (even over
  347.    calls to the inferior), (2) (in PC_IN_CALL_DUMMY [ON_STACK])
  348.    as the value of SP_REGNUM before the dummy frame was pushed.  These
  349.    two meanings would be incompatible for the 29k if we defined
  350.    CALL_DUMMY_LOCATION == ON_STACK (but we don't, so don't worry about it).
  351.    Also note that "lr1" below, while called a frame pointer
  352.    in the user's guide, has only one function:  To determine whether
  353.    registers need to be filled in the function epilogue.
  354.  
  355.    Consider the code:
  356.               < call bar>
  357.            loc1: . . .
  358.         bar:  sub gr1,gr1,rsize_b
  359.           . . .
  360.           add mfp,msp,0
  361.           sub msp,msp,msize_b
  362.           . . .
  363.           < call foo >
  364.     loc2: . . .
  365.         foo:  sub gr1,gr1,rsize_f
  366.           . . .
  367.           add mfp,msp,0
  368.           sub msp,msp,msize_f
  369.           . . .
  370.         loc3: < suppose the inferior stops here >
  371.  
  372.                    memory stack      register stack
  373.            |           |     |____________|
  374.            |           |     |____loc1____|
  375.       +------->|___________|     |            |   ^
  376.       |        | ^         |     |  locals_b  |   |
  377.       |        | |         |     |____________|   |
  378.       |        | |         |     |            |   | rsize_b
  379.       |        | | msize_b |     | args_to_f  |   |
  380.       |        | |         |     |____________|   |
  381.       |        | |         |     |____lr1_____|   V
  382.       |        | V         |     |____loc2____|<----------------+
  383.       |   +--->|___________|<---------mfp     |   ^             |
  384.       |   |    | ^         |     |  locals_f  |   |             |
  385.       |   |    | | msize_f |     |____________|   |             |
  386.       |   |    | |         |     |            |   | rsize_f     |
  387.       |   |    | V         |     |   args     |   |             |
  388.       |   |    |___________|<msp |____________|   |             |
  389.       |   |                      |_____lr1____|   V             |
  390.       |   |                      |___garbage__| <- gr1 <----+   |
  391.        |   |                                         |   |
  392.           |   |                                         |   |
  393.       |   |                               pc=loc3                    |   |
  394.       |   |                                           |   |
  395.       |   |                                           |   |
  396.       |   |            frame cache                              |   |
  397.           |   |       |_________________|                         |   |
  398.           |   |       |rsize=rsize_b    |                         |   |
  399.           |   |       |msize=msize_b    |                         |   |
  400.           +---|--------saved_msp        |                         |   |
  401.               |       |frame------------------------------------|---+
  402.               |       |pc=loc2          |                       |
  403.               |       |_________________|                       |
  404.               |       |rsize=rsize_f    |                       |
  405.               |       |msize=msize_f    |                       |
  406.               +--------saved_msp        |                       |
  407.                       |frame------------------------------------+
  408.                       |pc=loc3          |
  409.                       |_________________|
  410.  
  411.    So, is that sufficiently confusing?  Welcome to the 29000.
  412.    Notes:
  413.    * The frame for foo uses a memory frame pointer but the frame for
  414.      bar does not.  In the latter case the saved_msp is
  415.      computed by adding msize to the saved_msp of the
  416.      next frame.
  417.    * msize is in the frame cache only for high C's sake.  */
  418.  
  419. void read_register_stack ();
  420. long read_register_stack_integer ();
  421.  
  422. #define EXTRA_FRAME_INFO  \
  423.   CORE_ADDR saved_msp;    \
  424.   unsigned int rsize;     \
  425.   unsigned int msize;
  426.  
  427. /* Because INIT_FRAME_PC gets passed fromleaf, that's where we init
  428.    not only ->pc and ->frame, but all the extra stuff, when called from
  429.    get_prev_frame_info, that is.  */
  430. #define INIT_EXTRA_FRAME_INFO(fci) \
  431.   init_extra_frame_info(fci);
  432. void init_extra_frame_info ();
  433. #define INIT_FRAME_PC(fromleaf, fci) \
  434.   init_frame_pc(fromleaf, fci);
  435. void init_frame_pc ();
  436.  
  437. /* FRAME_CHAIN takes a FRAME
  438.    and produces the frame's chain-pointer.
  439.  
  440.    FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
  441.    and produces the nominal address of the caller frame.
  442.  
  443.    However, if FRAME_CHAIN_VALID returns zero,
  444.    it means the given frame is the outermost one and has no caller.
  445.    In that case, FRAME_CHAIN_COMBINE is not used.  */
  446.  
  447. /* On the 29k, the nominal address of a frame is the address on the
  448.    register stack of the return address (the one next to the incoming
  449.    arguments, not down at the bottom so nominal address == stack pointer).
  450.  
  451.    GDB expects "nominal address" to equal contents of FP_REGNUM,
  452.    at least when it comes time to create the innermost frame.
  453.    However, that doesn't work for us, so when creating the innermost
  454.    frame we set ->frame ourselves in INIT_EXTRA_FRAME_INFO.  */
  455.  
  456. /* These are mostly dummies for the 29k because INIT_FRAME_PC
  457.    sets prev->frame instead.  */
  458. #define FRAME_CHAIN(thisframe) (0)
  459.  
  460. /* Not sure how to figure out where the bottom frame is.  There is
  461.    no frame for start.  In my tests so far the
  462.    pc has been outside the text segment, though, so check for that.
  463.    FIXME!!!
  464.    However, allow a pc in a call dummy.  */
  465. #define FRAME_CHAIN_VALID(chain, thisframe) \
  466.   (outside_startup_file (FRAME_SAVED_PC (thisframe)))
  467.  
  468. #define FRAME_CHAIN_COMBINE(chain, thisframe) (0)
  469.  
  470. /* Define other aspects of the stack frame.  */
  471.  
  472. /* A macro that tells us whether the function invocation represented
  473.    by FI does not have a frame on the stack associated with it.  If it
  474.    does not, FRAMELESS is set to 1, else 0.  */
  475. #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
  476.   (FRAMELESS) = frameless_look_for_prologue(FI)
  477.  
  478. /* Saved pc (i.e. return address).  */
  479. #define FRAME_SAVED_PC(fraim) \
  480.   (read_register_stack_integer ((fraim)->frame + (fraim)->rsize, 4))
  481.  
  482. /* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their
  483.    offsets being relative to the memory stack pointer (high C) or
  484.    saved_msp (gcc).  */
  485.  
  486. #define FRAME_LOCALS_ADDRESS(fi) frame_locals_address (fi)
  487. extern CORE_ADDR frame_locals_address ();
  488.  
  489. /* Return number of args passed to a frame.
  490.    Can return -1, meaning no way to tell.  */
  491. /* While we could go the effort of finding the tags word and getting
  492.    the argcount field from it,
  493.    (1) It only counts arguments in registers, i.e. the first 16 words
  494.        of arguments
  495.    (2) It gives the number of arguments the function was declared with
  496.        not how many it was called with (or some variation, like all 16
  497.        words for varadic functions).  This makes argcount pretty much
  498.        redundant with -g info, even for varadic functions.
  499.    So don't bother.  */
  500. #define FRAME_NUM_ARGS(numargs, fi) ((numargs) = -1)
  501.  
  502. #define FRAME_ARGS_ADDRESS(fi) FRAME_LOCALS_ADDRESS (fi)
  503.  
  504. /* Return number of bytes at start of arglist that are not really args.  */
  505.  
  506. #define FRAME_ARGS_SKIP 0
  507.  
  508. /* Provide our own get_saved_register.  HAVE_REGISTER_WINDOWS is insufficient
  509.    because registers get renumbered on the 29k without getting saved.  */
  510.  
  511. #define GET_SAVED_REGISTER
  512.  
  513. /* Call function stuff.  */
  514.  
  515. /* The dummy frame looks like this (see also the general frame picture
  516.    above):
  517.  
  518.                     register stack
  519.  
  520.                               |                |  frame for function
  521.                                          |   locals_sproc |  executing at time
  522.                                       |________________|  of call_function.
  523.                                    |                   |  We must not disturb
  524.                                    |    args_out_sproc |  it.
  525.         memory stack               |________________|
  526.                                    |____lr1_sproc___|
  527.        |            |              |__retaddr_sproc_| <- gr1 (at start)
  528.        |____________|<-msp 0 <-----------mfp_dummy_____|
  529.        |            |  (at start)     |                |
  530.        | arg_slop   |              |  saved regs    |
  531.        | (16 words) |              | gr96-gr124     |
  532.        |____________|<-msp 1--after   | sr128-sr135    |
  533.        |            | PUSH_DUMMY_FRAME|                |
  534.        | struct ret |                 |________________|
  535.        | 17+        |                 |                |
  536.        |____________|<- lrp           | args_out_dummy |
  537.        | struct ret |              |  (16 words)    |
  538.        | 16         |              |________________|
  539.        | (16 words) |                 |____lr1_dummy___|
  540.        |____________|<- msp 2--after  |_retaddr_dummy__|<- gr1 after
  541.        |            | struct ret      |                |   PUSH_DUMMY_FRAME
  542.        | margs17+   | area allocated  |  locals_inf    |
  543.        |            |                 |________________|    called
  544.        |____________|<- msp 4--when   |                |    function's
  545.        |            |   inf called    | args_out_inf   |    frame (set up
  546.        | margs16    |                 |________________|    by called
  547.        | (16 words) |                 |_____lr1_inf____|    function).
  548.        |____________|<- msp 3--after  |       .        |
  549.        |            |   args pushed   |       .        |
  550.        |            |                  |       .        |
  551.                                       |                |
  552.  
  553.    arg_slop: This area is so that when the call dummy adds 16 words to
  554.       the msp, it won't end up larger than mfp_dummy (it is needed in the
  555.       case where margs and struct_ret do not add up to at least 16 words).
  556.    struct ret:  This area is allocated by GDB if the return value is more
  557.       than 16 words.  struct ret_16 is not used on the 29k.
  558.    margs:  Pushed by GDB.  The call dummy copies the first 16 words to
  559.       args_out_dummy.
  560.    retaddr_sproc:  Contains the PC at the time we call the function.
  561.       set by PUSH_DUMMY_FRAME and read by POP_FRAME.
  562.    retaddr_dummy:  This points to a breakpoint instruction in the dummy.  */
  563.  
  564. /* Rsize for dummy frame, in bytes.  */
  565.  
  566. /* Bytes for outgoing args, lr1, and retaddr.  */
  567. #define DUMMY_ARG (2 * 4 + 16 * 4)
  568.  
  569. /* Number of special registers (sr128-) to save.  */
  570. #define DUMMY_SAVE_SR128 8
  571. /* Number of general (gr96- or gr64-) registers to save.  */
  572. #define DUMMY_SAVE_GREGS 29
  573.  
  574. #define DUMMY_FRAME_RSIZE \
  575. (4 /* mfp_dummy */                                             \
  576.  + DUMMY_SAVE_GREGS * 4                             \
  577.  + DUMMY_SAVE_SR128 * 4                   \
  578.  + DUMMY_ARG                       \
  579.  )
  580.  
  581. /* Push an empty stack frame, to record the current PC, etc.  */
  582.  
  583. #define PUSH_DUMMY_FRAME push_dummy_frame();
  584. extern void push_dummy_frame ();
  585.  
  586. /* Discard from the stack the innermost frame,
  587.    restoring all saved registers.  */
  588.  
  589. #define POP_FRAME pop_frame ();
  590. extern void pop_frame ();
  591.  
  592. /* This sequence of words is the instructions
  593.    mtsrim cr, 15
  594.    loadm 0, 0, lr2, msp     ; load first 16 words of arguments into registers
  595.    add msp, msp, 16 * 4     ; point to the remaining arguments
  596.   CONST_INSN:
  597.    const gr96,inf
  598.    consth gr96,inf
  599.    calli lr0, gr96
  600.    aseq 0x40,gr1,gr1   ; nop
  601.    asneq 0x50,gr1,gr1  ; breakpoint
  602.    */
  603.  
  604. /* Position of the "const" instruction within CALL_DUMMY in bytes.  */
  605. #define CONST_INSN (3 * 4)
  606. #if TARGET_BYTE_ORDER == HOST_BYTE_ORDER
  607. #define CALL_DUMMY {0x0400870f, 0x3600827d, 0x157d7d40, 0x03ff60ff,    \
  608.             0x02ff60ff, 0xc8008060, 0x70400101, 0x72500101}
  609. #else /* Byte order differs.  */
  610.   you lose
  611. #endif /* Byte order differs.  */
  612. #define CALL_DUMMY_LENGTH (8 * 4)
  613.  
  614. #define CALL_DUMMY_START_OFFSET 0  /* Start execution at beginning of dummy */
  615.  
  616. /* Helper macro for FIX_CALL_DUMMY.  WORDP is a long * which points to a
  617.    word in target byte order; bits 0-7 and 16-23 of *WORDP are replaced with
  618.    bits 0-7 and 8-15 of DATA (which is in host byte order).  */
  619.  
  620. #if TARGET_BYTE_ORDER == BIG_ENDIAN
  621. #define STUFF_I16(WORDP, DATA) \
  622.   { \
  623.     *((char *)(WORDP) + 3) = ((DATA) & 0xff);\
  624.     *((char *)(WORDP) + 1) = (((DATA) >> 8) & 0xff);\
  625.   }
  626. #else /* Target is little endian.  */
  627. #define STUFF_I16(WORDP, DATA) \
  628.   {
  629.     *(char *)(WORDP) = ((DATA) & 0xff);
  630.     *((char *)(WORDP) + 2) = (((DATA) >> 8) & 0xff);
  631.   }
  632. #endif /* Target is little endian.  */
  633.  
  634. /* Insert the specified number of args and function address
  635.    into a call sequence of the above form stored at DUMMYNAME.  */
  636.  
  637. /* Currently this stuffs in the address of the function that we are calling.
  638.    If different 29k systems use different breakpoint instructions, it
  639.    could also stuff BREAKPOINT in the right place (to avoid having to
  640.    duplicate CALL_DUMMY in each tm-*.h file).  */
  641.  
  642. #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p)   \
  643.   {\
  644.     STUFF_I16((char *)dummyname + CONST_INSN, fun);\
  645.     STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16);\
  646.   }
  647.  
  648. /* 29k architecture has separate data & instruction memories -- wired to
  649.    different pins on the chip -- and can't execute the data memory.
  650.    Also, there should be space after text_end;
  651.    we won't get a SIGSEGV or scribble on data space.  */
  652.  
  653. #define CALL_DUMMY_LOCATION AFTER_TEXT_END
  654.  
  655. /* Because of this, we need (as a kludge) to know the addresses of the
  656.    text section.  */
  657.  
  658. #define    NEED_TEXT_START_END
  659.  
  660. /* How to translate register numbers in the .stab's into gdb's internal register
  661.    numbers.  We don't translate them, but we warn if an invalid register
  662.    number is seen.  Note that FIXME, we use the value "sym" as an implicit
  663.    argument in printing the error message.  It happens to be available where
  664.    this macro is used.  (This macro definition appeared in a late revision
  665.    of gdb-3.91.6 and is not well tested.  Also, it should be a "complaint".) */
  666.  
  667. #define    STAB_REG_TO_REGNUM(num) \
  668.     (((num) > LR0_REGNUM + 127) \
  669.        ? fprintf(stderr,     \
  670.         "Invalid register number %d in symbol table entry for %s\n", \
  671.              (num), SYMBOL_NAME (sym)), (num)    \
  672.        : (num))
  673.